package com.ymchen.ranniservice.gateway.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

import java.util.HashMap;
import java.util.Map;


@Slf4j
@RestController
public class FallbackController {

    @RequestMapping("fallback/{name}")
    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    public Mono<Map<String, Object>> systemFallback(@PathVariable String name) {
        Map<String, Object> map = new HashMap<>();
        String response = "服务访问超时，请稍后再试";
        log.error("{}，目标微服务：{}", response, name);
        map.put("msg", response);
        return Mono.just(map);
    }

}
